import { EntitySchema } from '@mikro-orm/core';

export class LeCoupon {
  id!: string;
  name!: string;
  type: boolean = true;
  discount!: string;
  totalNum!: string;
  expireType!: boolean;
  expireDay!: string;
  beginTime!: string;
  endTime!: string;
  minPrice!: string;
  subPrice!: string;
  appointType!: boolean;
  giveLimit?: boolean;
  enableShare: boolean = false;
  expireRemind?: number;
  enableRefund: boolean = false;
  content?: string;
  AppID!: string;
  merchantId!: string;
  createdTime?: number = 0;
  updatedTime?: number = 0;
  deletedTime?: number = 0;
  isRecycle?: boolean = false;
  isDeleted?: number = 0;
  appointData?: string;
  status: boolean = false;
  overNum!: string;
  registerLimit: boolean = false;
}

export const LeCouponSchema = new EntitySchema({
  class: LeCoupon,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    name: { type: 'string', length: 100 },
    type: { type: 'boolean', default: true },
    discount: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `10.00` },
    totalNum: { type: 'string', columnType: 'bigint' },
    expireType: { type: 'boolean' },
    expireDay: { type: 'string', columnType: 'bigint', defaultRaw: `1` },
    beginTime: { type: 'string', columnType: 'bigint', defaultRaw: `0` },
    endTime: { type: 'string', columnType: 'bigint', defaultRaw: `0` },
    minPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    subPrice: { type: 'string', columnType: 'numeric(10,2)' },
    appointType: { type: 'boolean' },
    giveLimit: { type: 'boolean', nullable: true },
    enableShare: { type: 'boolean', default: false },
    expireRemind: { type: 'number', nullable: true },
    enableRefund: { type: 'boolean', default: false },
    content: { type: 'string', columnType: 'text', nullable: true },
    AppID: { type: 'string', fieldName: 'AppID', length: 50 },
    merchantId: { type: 'string', columnType: 'bigint' },
    createdTime: { type: 'number', nullable: true, default: 0 },
    updatedTime: { type: 'number', nullable: true, default: 0 },
    deletedTime: { type: 'number', nullable: true, default: 0 },
    isRecycle: { type: 'boolean', nullable: true, default: false },
    isDeleted: { type: 'number', columnType: 'tinyint', nullable: true, default: 0 },
    appointData: { type: 'string', columnType: 'text', nullable: true },
    status: { type: 'boolean', default: false },
    overNum: { type: 'string', columnType: 'bigint' },
    registerLimit: { type: 'boolean', default: false },
  },
});
